<%-- 
    Document   : s2
    Created on : 2014/3/3, 下午 02:59:32
    Author     : Gjun
--%>

<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Filter.DAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%  
 String number=request.getParameter("number");
 
    String sql="select top "+number+"a.img_url,a.product_name,SUM(b.order_quantity)as 總數量 from product as a,order_detail as b where b.product_id = a.product_id group by a.product_name,a.img_url order by 總數量 desc";
    DAO db = new DAO();
    ArrayList<HashMap> rslist= db.query(sql, new String[]{});    
 HashMap smap ; 
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <style>
            #size{
                width:400px;
                height:300px;
            }
            #listbox{
                border-style: solid;
                border-width: 2px;             
            }
            body{background-color:#EEE;}
            .BOX{width: available;
                 height: 100px ;
                
                
                 position: absolute;
                 left: 25%;
                 top:  30%;
                 
                 margin-top:  -150px;
                 margin-left:  -150px;} 
           
        </style>
    </head>
    <body>
        <table id="table" border="1"> 
              
                <th colspan="2" id="table"> 產品資訊</th><th id="table">數量</th>
        <%
                  for(int i =0;i<rslist.size();i++)
                  {
                      smap =rslist.get(i);                  
                     out.println("<tr><td><img src='"+smap.get("img_url")
                                +"' style='width:160px;height:120px;'/> </td><td>"
                                +smap.get("product_name")+
                              "</td><td align='right'>"
                                +smap.get("總數量")
                                +"</td></tr></th>");
                  }
        %>
           <br>
           <a href='ProductManagement.jsp'>返回產品管理列表</a>
          <br>
     </table>
        </body>
</html>
